<?php

namespace app\data\controller\api;

use app\data\service\CarService;
use app\data\service\UserAdminService;
use think\admin\Controller;

/**
 * 用户资料
 * Class User
 * @package app\data\controller\api
 */
class User extends Controller
{
    /**
     * 获取用户资料
     */
    public function getUserInfo()
    {
        $user = UserAdminService::instance()->get(input('uuid', 0));
        if (empty($user)) {
            $this->error('查无用户信息');
        }
        if (!empty($user['id_card'])) {
            $user['is_certified'] = 1;
        } else {
            $user['is_certified'] = 0;
        }
        $user['is_band_bank'] = UserAdminService::instance()->isBindBankByUserId($user['id'] ?? 0);
        $user['is_service_provider'] = UserAdminService::instance()->isServiceProvider($user);
        $user['has_car'] = CarService::instance()->hasCar($user['id'] ?? 0);

        $this->success('获取用户资料', $user);
    }
}